
# 构建树形
import os


from src.main.util.ApplicationConfig import ApplicationConfig


def build_tree(modules, parent_id=None):
    tree = []
    for module in modules:
        if module['parent_module_id'] == parent_id:
            children = build_tree(modules, module['module_id'])
            if children:
                module['children'] = children
            tree.append(module)
    return tree